<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('category_modules', function (Blueprint $table) {
            $table->id();
            $table->integer('category_id')->comment('年级id')->index();
            $table->tinyInteger('type')->default(1)->comment('1小学 2初中')->index();
            $table->string('name')->comment('模块名称');
            $table->tinyInteger('module_type')->default(1)->comment('1情境学习 2单元词汇表 3常用表达法/语法聚焦 4背单词 5歌曲歌谣')->index();
            $table->tinyInteger('ui')->default(1)->comment('ui 版本 1：11套教材 2：12套教材')->index();
            $table->tinyInteger('is_open')->default(1)->comment('是否开启 1开启 0关闭')->index();
            $table->timestamps();

            $table->index(['category_id', 'type']);
            $table->index(['type', 'ui']);
            $table->index(['is_open', 'module_type']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('category_modules');
    }
};
